package com.todo.partner.application.frontend.controller;

import com.todo.common.common.entity.response.BizPageResponse;
import com.todo.common.common.entity.response.BizResponse;
import com.todo.partner.application.frontend.service.PartnerContentAggService;
import com.todo.partner.iface.frontend.ContentPartnerFrontendIface;
import com.todo.partner.iface.frontend.request.*;
import com.todo.partner.iface.frontend.response.ContentPartnerBaseVO;
import com.todo.partner.iface.frontend.response.ContentPartnerDetailVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author azhebuxing
 * @date 2024/6/4 14:12
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/partner")
@Tag(name = "内容搭子前台接口", description = "内容搭子前台接口")
public class ContentPartnerFrontendController implements ContentPartnerFrontendIface {

    @Resource
    private PartnerContentAggService partnerContentAggService;

    @Override
    @Operation(summary = "新增搭子内容")
    @PostMapping("/insertContentPartner")
    public BizResponse<Boolean> insertContentPartner(@RequestBody InsertContentPartnerParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return partnerContentAggService.insertContentPartner(param);
    }

    @Override
    @Operation(summary = "更新搭子内容")
    @PostMapping("/updateContentPartnerById")
    public BizResponse<Boolean> updateContentPartnerById(@RequestBody UpdateContentPartnerByIdParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return partnerContentAggService.updateContentPartnerById(param);
    }

    @Override
    @Operation(summary = "根据主键删除搭子内容")
    @PostMapping("/removeContentPartnerById")
    public BizResponse<Boolean> removeContentPartnerById(@RequestBody RemoveContentPartnerByIdParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return partnerContentAggService.removeContentPartnerById(param);
    }

    @Override
    @Operation(summary = "查询搭子内容详情")
    @PostMapping("/queryContentPartnerDetail")
    public BizResponse<ContentPartnerDetailVO> queryContentPartnerDetail(@RequestBody QueryContentPartnerDetailParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return partnerContentAggService.queryContentPartnerDetail(param);
    }

    @Override
    @Operation(summary = "分页查询搭子内容信息")
    @PostMapping("/queryContentPartnerByPage")
    public BizPageResponse<ContentPartnerBaseVO> queryContentPartnerByPage(@RequestBody QueryContentPartnerByPageParam param) {
        if (param == null) {
            return BizPageResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizPageResponse.success("查询失败，请刷新后重新操作");
        }
        return partnerContentAggService.queryContentPartnerByPage(param);
    }
}
